const Koa = require('koa');
const app = new Koa();
const views = require('koa-views');
const router = require('koa-router')();

const json = require('koa-json');
const onerror = require('koa-onerror');
const bodyparser = require('koa-bodyparser')();
const logger = require('koa-logger');

const index = require('./public/index');

// error handler
onerror(app);

// middlewares
app.use(bodyparser);
app.use(json());
// app.use(logger());
app.use(require('koa-static')(__dirname + '/public'));

app.use(views(__dirname + '/views', {
  extension: 'ejs'
}));

// index routes
app.use(index.routes(), index.allowedMethods());

// front end routes poxy
// app.use(routes.routes());

// start server
app.listen(3300,() => {
  console.log('open ','127.0.0.1:3300')
})
